<template name="home">
	<view>
		<scroll-view>
			<!-- 轮播 -->
<!-- 			<swiper class="screen-swiper square-dot"  :indicator-dots="true" :circular="true"
			 :autoplay="true" interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
				<swiper-item v-for="(item,index) in swiperList" :key="index">
					<image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
					<video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
				</swiper-item>
			</swiper> -->
			
			<!-- 本日数据 -->
			<view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
				<view class="action">
					<text class='cuIcon-title text-blue'></text>本日数据
				</view>
			</view>
				
			<view class="cu-list grid col-3 text-df">
				<view class="cu-item animation-slide-bottom"    @tap="goPage('userMainList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(0)}}</block>
							</view>
						<view class="margin-top-xs">主账户数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('userSubAccountList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(1)}}</block>
							</view>
						<view class="margin-top-xs">子账户数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('CustomerLinkmanList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(2)}}</block>
							</view>
						<view class="margin-top-xs">收货人数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('baseRegisterList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(3)}}</block>
							</view>
						<view class="margin-top-xs">注册人数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(4)}}</block>
							</view>
						<view class="margin-top-xs">签收数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(5)}}</block>
							</view>
						<view class="margin-top-xs">存证文件数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(6)}}</block>
							</view>
						<view class="margin-top-xs">货单/服务数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(7)}}</block>
							</view>
						<view class="margin-top-xs">对账函数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(24)}}</block>
							</view>
						<view class="margin-top-xs">认证记录数</view>
					</view>
				</view>
			</view>
			
			<!-- 本月数据 -->
			<view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
				<view class="action">
					<text class='cuIcon-title text-blue'></text>本月数据
				</view>
			</view>
				
			<view class="cu-list grid col-3 text-df">
				<view class="cu-item animation-slide-bottom"    @tap="goPage('userMainList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(8)}}</block>
							</view>
						<view class="margin-top-xs">主账户数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('userSubAccountList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(9)}}</block>
							</view>
						<view class="margin-top-xs">子账户数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('CustomerLinkmanList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(10)}}</block>
							</view>
						<view class="margin-top-xs">收货人数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage('baseRegisterList')">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(11)}}</block>
							</view>
						<view class="margin-top-xs">注册人数</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(12)}}</block>
							</view>
						<view class="margin-top-xs">签收数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(13)}}</block>
							</view>
						<view class="margin-top-xs">存证文件数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(14)}}</block>
							</view>
						<view class="margin-top-xs">货单/服务数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(15)}}</block>
							</view>
						<view class="margin-top-xs">对账函数量</view>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
					<view class="padding text-center">
							<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
							   <block >{{getDataInfo(25)}}</block>
							</view>
						<view class="margin-top-xs">认证记录数</view>
					</view>
				</view>
			</view>
				<!-- 累计数据 -->
				<view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
					<view class="action">
						<text class='cuIcon-title text-blue'></text>累计数据
					</view>
				</view>
					
				<view class="cu-list grid col-3 text-df">
					<view class="cu-item animation-slide-bottom"    @tap="goPage('userMainList')">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(16)}}</block>
								</view>
							<view class="margin-top-xs">主账户数</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage('userSubAccountList')">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(17)}}</block>
								</view>
							<view class="margin-top-xs">子账户数</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage('CustomerLinkmanList')">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(18)}}</block>
								</view>
							<view class="margin-top-xs">收货人数量</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage('baseRegisterList')">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(19)}}</block>
								</view>
							<view class="margin-top-xs">注册人数</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(20)}}</block>
								</view>
							<view class="margin-top-xs">签收数量</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(21)}}</block>
								</view>
							<view class="margin-top-xs">存证文件数量</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(22)}}</block>
								</view>
							<view class="margin-top-xs">货单/服务数量</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(23)}}</block>
								</view>
							<view class="margin-top-xs">对账函数量</view>
						</view>
					</view>
					<view class="cu-item animation-slide-bottom"    @tap="goPage(item.page)">
						<view class="padding text-center">
								<view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" >
								   <block >{{getDataInfo(26)}}</block>
								</view>
							<view class="margin-top-xs">认证记录数</view>
						</view>
					</view>
				</view>
		</scroll-view>
		<view class="cu-tabbar-height margin-top"></view>
	</view>
</template>

<script>
	import { us,os } from '@/common/util/work.js'
	import socket from '@/common/js-sdk/socket/socket.js'
	import configService from '@/common/service/config.service.js'
	export default {
		name: 'home',
		props:{
			cur:String,
		},
		watch: {
			cur: {
				immediate: true,
				handler:function(val,oldVal){
					console.log('cur',val,oldVal)
				    this.initMenu()
				},
			},
		},
		data() {
			return {
			 swiperList: [
				  {id:1,type: 'image',url: '/static/banner/banner1.png', link: ''},
				  {id:2,type: 'image',url: '/static/banner/banner2.jpg', link: ''},
				  {id:3,type: 'image',url: '/static/banner/banner3.jpg', link: ''},
				  {id:4,type: 'image',url: '/static/banner/banner4.jpg', link: ''},
				],
				middleApps: [
				  {icon: 'line2_icon1.png', title: '审批', 'text': '个人审批'},
				  {icon: 'line2_icon2.png', title: '审批稿', 'text': '审批草稿箱'},
				],
				usList:us.data,
				osList:os.data,
				entity:{},
				VeriRecordNumberEntity:{},
				msgCount:0,
				dot:{
				  mailHome:false
				}
			}
		},
		methods: {
			initMenu(){
				console.log("-----------home------------")
			    this.onSocketOpen()
			    this.onSocketReceive()
			    this.loadCount(0);
			},
			goPage(page){
				if(!page){
					return false;
				}
				if(page==='annotationList'){
				  this.msgCount = 0
				}
				this.dot[page]=false
				this.$Router.push({name: page})
			},
			// 启动webSocket
			onSocketOpen() {
				socket.init('websocket');
			},
			onSocketReceive() {
				var _this=this
				socket.acceptMessage = function(res){
					// console.log("页面收到的消息", res);
					if(res.cmd == "topic"){
					  //系统通知
					  _this.loadCount('1')
					}else if(res.cmd == "user"){
					  //用户消息
					  _this.loadCount('2')
					} else if(res.cmd == 'email'){
					 //邮件消息
					  _this.loadEmailCount()
					}
				}
			},
			loadCount(flag){
				console.log("loadCount::flag",flag)
				let url = '/Base_Manage/Home/GetStatisData';
				this.$http.post(url).then(res=>{
					console.log("res::",res)
					console.log("res::",res.data.Success)
				  if(res.data.Success){
					this.entity = res.data.Data
					console.log("resJson.Data",res.data.Data)
				  }
				}).catch(res=>{
					uni.navigateTo({
						url: `/pages/login/login` 
						});;
				})
				
				console.log("url",this.$http.config.baseUrl)
				
				//let veriUrl='http://192.168.1.24:8888/auth/VeriRecord/number';
				// let veriUrl='https://veri.yoojet.com/auth/VeriRecord/number';
				// uni.request({
				// 	url: veriUrl,
				// 	method: 'get',
				// 	success: async (res) => {
				// 		if(res!= null){
				// 			this.VeriRecordNumberEntity = res.data
				// 			console.log("resJson.Data",res.data)
				// 		}
				// 	}
				// })				
			},
			loadEmailCount(){
				this.dot.mailHome = true
			},
			getTtemDotInfo(item){
				if(item.page==='annotationList' && this.msgCount>0){
				  return this.msgCount
				}
				return '';
			},
			getDataInfo (num) {
			  if (this.entity) {
				if (this.entity[num]) {
				  return this.entity[num].Count
				} else {
				  return 0
				}
			  } else {
				return 0
			  }
			}
		}
	}
</script>

<style scoped>
	.cu-list.grid>.cu-item {
	  padding: 0px 0px; 
	}
    .line2-icon {
	  width: 60px;
	  height: 60px;
    }
	
</style>
